package com.easy.auth.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.easy.auth.domain.Impreport;
import com.easy.auth.domain.Waring;
import com.easy.auth.service.ImpreportService;
import com.easy.common.jdbc.PageInfo;
import com.easy.common.web.FilterUtil;
import com.easy.common.web.PagedList;
import com.easy.common.web.message.DeleteMessage;
import com.easy.common.web.message.Message;
import com.easy.common.web.message.SaveOrEditMessage;

@Controller
@RequestMapping("ImpreportController")
public class ImpreportController {

	@Autowired
	private ImpreportService ImpreportService;

	@RequestMapping("goToImpreportManager")
	public String goToActionManager(String secondMenuId,HttpServletRequest request) {
		request.getSession().setAttribute("secondMenuId", secondMenuId);
		return "auth/Impreport";
	}

	/**
	 * 查询全部节点数据
	 * 
	 * @return
	 */
	@RequestMapping("getImpreportList")
	@ResponseBody
	public PagedList<Impreport> getImpreportList(PageInfo pageInfo) {
		Impreport impreport = (Impreport) FilterUtil.getVO(Impreport.class,
				pageInfo.getFilterRules());
		return ImpreportService.getImpreportList(impreport, pageInfo);
	}

	/**
	 * 根据oid查询该节点其他数据
	 * 
	 * @return
	 */
	@RequestMapping("findImpreportById")
	@ResponseBody
	public Impreport findImpreportById(Impreport Impreport) {
		return ImpreportService.findImpreportById(Impreport);
	}

	/**
	 * 保存资源信息
	 * 
	 * @param param
	 * @param request
	 * @return
	 */
	@RequestMapping("saveOrEditImpreport")
	@ResponseBody
	public Message saveTreegridItem(Impreport Impreport) {
		int count = ImpreportService.saveImpreport(Impreport);
		return new SaveOrEditMessage(count);
	}

	/**
	 * 删除资源信息
	 * 
	 * @param param
	 * @param request
	 * @return
	 */
	@RequestMapping("removeImpreport")
	@ResponseBody
	public Message removeTreegridItem(String oids) {
		String[] ids = oids.split("-");
		return new DeleteMessage(ImpreportService.removeImpreport(ids));
	}

}
